package com.yanqu.road.server.cmd.vehiclestone;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.vehicle.VehicleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleBoneModule;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.S_VBONE_BONE_HOLE_UNLOCK, desc = "魂骨重置")
public class VehicleBoneHoleUnlockCmd extends AbstractCommand {


	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		VehicleProto.VehicleBoneHoleUnlockReqMsg reqMsg = VehicleProto.VehicleBoneHoleUnlockReqMsg.parseFrom(packet.getBytes());
		ret = player.getModule(VehicleBoneModule.class).unlockHole(reqMsg.getVehicleUid(), reqMsg.getPos());
	}

	@Override
	public void sendData(GamePlayer player) {
		if (ret != 0) {
			//获得注解的code
			int code = this.getClass().getAnnotation(Cmd.class).code();
			int backClientProtocol = code % 10000;
			player.sendPacket(backClientProtocol, VehicleProto.VehicleBoneLvUpRespMsg.newBuilder().setRet(ret));
		}
	}

}
